package com.pcsky.view;

import java.awt.EventQueue;
import java.util.Vector;

import javax.swing.JDialog;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import com.pcsky.dao.DatabaseUtil;
import com.pcsky.dao.LineDao;

public class TestDialogJtable extends JDialog {
	private JTable table;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					TestDialogJtable dialog = new TestDialogJtable();
					dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
					dialog.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the dialog.
	 */
	public TestDialogJtable() {
		setBounds(100, 100, 450, 300);
		LineDao dao = new LineDao();
		dao.setConnection(DatabaseUtil.getConnection());
		Vector<Vector>  loadDatas = dao.listAllVt();
		Vector<String> vheader = new Vector<String>();
		vheader.add("id");
		vheader.add("name");
		DefaultTableModel model = new DefaultTableModel(loadDatas, vheader) {
			public boolean isCellEditable(int row, int column) {
				return false;
			};
		};
		getContentPane().setLayout(null);
		
		table = new JTable();
		table.setModel(model);
//		table.setBounds(0, 0, 1, 1);
//		getContentPane().add(table);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(0, 0, 364, 273);
		scrollPane.setViewportView(table);
		getContentPane().add(scrollPane);
		table.updateUI();

	}
}
